import libnum
from Crypto.Cipher import AES

a = 56631233292325412205528754798133970783633216936302049893130220461139160682777
b = libnum.n2s(a)

hint = b[:4] * 8
hint1 = libnum.s2n(hint)
key = hint1 ^ a
print(key)


def decrypto(message, key):
    aes = AES.new(key, AES.MODE_ECB)
    return aes.decrypt(message)


c1 = 0x3c976c92aff4095a23e885b195077b66
msg = b'Welcome to this competition, I hope you can have fun today!!!!!!'
msg1 = []
for i in range(0, len(msg), 16):
    tmp = msg[i:i + 16]
    msg1.append(tmp)
print(msg1)
msg2 = msg1[::-1]
print(msg2)

for i in msg2:
    tmp = decrypto(libnum.n2s(c1), libnum.n2s(key))
    c1 = libnum.s2n(tmp) ^ libnum.s2n(i)
    print(c1)
    print(libnum.n2s(c1))
